public class StringDemo6 {
    public static void main(String[] args) {
        int[]arr={1,2,3,4,5,6};
        String s1=arrToString(arr);
        System.out.println(s1);
    }


    public static String arrToString(int arr[]){
        if(arr==null){
            return "";
        }
        if(arr.length==0){
            return "[]";
        }
        String s1="[";
        for(int i=0;i<arr.length;i++){

            s1=s1+arr[i];
            if(i==arr.length-1){
                s1+=']';
                break;
            }
            s1=s1+',';
        }
        return s1;
    }
}
